<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>OA办公自动化应用系统</title>
<link href="__PUBLIC__/images/favicon.ico" type="image/x-icon" rel="icon" />
<link href="__PUBLIC__/images/favicon.ico" type="image/x-icon" rel="shortcut icon" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<import type="css" file="css.login" />
<import type="js" file="js.jquery" />
<import type="js" file="js.jquery#form" />
</head>
<body scroll="auto">

<div id="logo">
   <div id="form">
      <div class="left">
         <div class="user"><input type="text" class="text" name="user_name" maxlength="20" onmouseover="this.focus()" onfocus="this.select()" value=""></div>
         <div class="pwd"><input type="password" class="text" name="password" onmouseover="this.focus()" onfocus="this.select()" value=""></div>
      </div>
      <div class="right">
         <input type="submit" class="submit" title="登录" value="" onclick="sub_ajax()" />
      </div>
   </div>
      <div class="warning"></div>
</div>
<script type="text/javascript">
/*
$(document).ready(function(){
	var option = {
			beforeSubmit : CheckForm,
			success : complete,
			error : warning,
			type : 'post',
	};
	$("#form1").submit(function(){
		$(this).ajaxSubmit(option);return false;
	});
});
*/
var url = "__APP__/Login/check_login";
function sub_ajax(){
	CheckForm();
	$.post(url, {user_name: $("input[name='user_name']").val(), password: $("input[name='password']").val()}, function(data){
		if( data.status == 1 ){
			$(".warning").html("<font color='#458B00'>用户名密码验证通过！</font>");
			setTimeout( location.href="__ROOT__/", 1000 );
		}else{
			$(".warning").html(data.info);
		}	
	});
	
}

function CheckForm()
{
	$('.warning').html("正在进行登录验证...");
	var re=/^[a-z0-9]*$/;
	var username = $("input[name='user_name']").val();
    if(username=="")
    {
    	$(".warning").html("用户名不能为空！");
      	return false;
    }else{
		if(!re.test(username)){
			$(".warning").html("用户名只能为小写字母或数字！");
			return false;
		}else if(username.length>20){
			$(".warning").html("用户名字符长度不能超过20个字节！");
			return false;
		}
    }
	if($("input[name='password']").val()=="")
	{ 
		$(".warning").html("密码不能为空！");
		return false;
	}
}

function complete( data ){
	if( data.status == 1 ){
		$(".warning").html("<font color='#458B00'>用户名密码验证通过！</font>");
		setTimeout( location.href="__ROOT__/", 1000 );
	}else{
		$(".warning").html(data.info);
	}
}

function warning(data){
	$(".warning").html(data.massage);
}
</script>
</body>
</html>